package leecode

import "math"

func maxSales(sales []int) int {
	var sum int //前缀和
	result := math.MinInt
	for i := 0; i < len(sales); i++ {
		sum = sum + sales[i]
		if sum > result {
			result = sum
		}
		if sum < 0 {
			sum = 0
		}
	}
	return result
}
